#include "Frm06.h"

Frm06::Frm06(HmiApp* app, STTWidget *par, const string& id, const string& desc) : STTPage(app->getRuntime(), par, id, desc) {
	hmiApp = app;
}

Frm06::~Frm06() {
}

void Frm06::onInit() {

}

void Frm06::createParts() {
	setMainArg(0, 0, 1024, 600);
	setMainStyle(0, 0xffffff, 0xffffff, 0, 255, 0, 0xc0c0c0);

	/*----------------------------- Image : wMImage2                     -----------------------------*/
	wMImage2 = new STTImage(p_rt, this, "wMImage2");
	wMImage2->setMainArg(509, 0, 200, 200);
	wMImage2->addStateImg("0", "./images/img17369985455960_200X200R0.png");

	/*----------------------------- Image : wMImage1                     -----------------------------*/
	wMImage1 = new STTImage(p_rt, this, "wMImage1");
	wMImage1->setMainArg(509, 0, 200, 200);
	wMImage1->addStateImg("0", "./images/img17369985960200_200X200R0.png");

	/*----------------------------- Button : wMButton1                   -----------------------------*/
	wMButton1 = new STTButton(p_rt, this, "wMButton1", 0);
	wMButton1->setMainArg(312, 64, 98, 48, false);
	wMButton1->setPressedArg("停止动画", 0x0, "文泉驿微米黑", 16, 0);
	wMButton1->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton1->setReleasedArg("停止动画", 0x0, "文泉驿微米黑", 16, 0);
	wMButton1->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton1->onEventHandler(Event::CLICKED, this, (EHandler) & Frm06::wMButton1_clk_cb);

	/*----------------------------- Button : wMButton3                   -----------------------------*/
	wMButton3 = new STTButton(p_rt, this, "wMButton3", 0);
	wMButton3->setMainArg(312, 15, 98, 48, false);
	wMButton3->setPressedArg("启动动画", 0x0, "文泉驿微米黑", 16, 0);
	wMButton3->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton3->setReleasedArg("启动动画", 0x0, "文泉驿微米黑", 16, 0);
	wMButton3->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton3->onEventHandler(Event::CLICKED, this, (EHandler) & Frm06::wMButton3_clk_cb);

	/*----------------------------- Button : wMButton4                   -----------------------------*/
	wMButton4 = new STTButton(p_rt, this, "wMButton4", 0);
	wMButton4->setMainArg(1, 1, 98, 48, false);
	wMButton4->setPressedArg("返回主页", 0x0, "文泉驿微米黑", 16, 0);
	wMButton4->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton4->setReleasedArg("返回主页", 0x0, "文泉驿微米黑", 16, 0);
	wMButton4->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton4->bindOpenFormHandler(Event::CLICKED, "Frm03", PageMode::NEWWIN, NULL);

	/*called after widget created.*/

	return; //createParts END
}

static void valuecb(void* obj, int32_t v) {
	STTImage* widget = (STTImage*)obj;
	widget->setAngle(v/10.0);
}

void Frm06::onLoad() {

}

bool Frm06::onClosing() {
	return true;
}

void Frm06::onDispose() {

}

void Frm06::wMButton1_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton1（功能键）的点击事件*/
	wMImage1->getStyle()->p_anim->stopAnim(wMImage1);

}

void Frm06::wMButton3_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton1（功能键）的点击事件*/
	wMImage1->getStyle()->p_anim->doAnim(wMImage1,0,-3600,2000,valuecb,NULL,-1);
}
